using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;

namespace HadronData
{
    [ContentTypeWriter]
    public class PolygonContentTypeWriter : ContentTypeWriter<Polygon>
    {
        protected override void Write(ContentWriter p_contentWriter, Polygon p_polygon)
        {
            StringBuilder stringBuilder = new StringBuilder();
            foreach (Vector2 vecVertex in p_polygon.Vertices)
            {
                if (stringBuilder.Length > 0)
                    stringBuilder.Append(" ");

                stringBuilder.Append(vecVertex.X);
                stringBuilder.Append(" ");
                stringBuilder.Append(vecVertex.Y);
            }

            p_contentWriter.Write(stringBuilder.ToString());
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(PolygonContentTypeReader).AssemblyQualifiedName;
        }
    }
}
